<?php

use App\Http\Controllers\Api\CardController;
use App\Http\Controllers\Api\PayController;
use App\Http\Controllers\Api\ReportController;
use App\Http\Controllers\Api\SystemController;
use App\Http\Controllers\Api\TopUpController;
use App\Http\Controllers\Api\UserController;
use App\Http\Middleware\AuthMiddleware;
use Illuminate\Support\Facades\Route;

// 无需鉴权
Route::prefix('v1')->group(function(){
    // 用户注册
    Route::post('/user/register', [UserController::class, 'register']);
    // 用户登录
    Route::post('/user/login', [UserController::class, 'login']);

    // 获取系统参数
    Route::get('/system/get_env_info', [SystemController::class, 'get_env_info']);

    // 确认支付
    Route::post('/pay/confirm_pay', [PayController::class, 'confirm']);
    // 支付宝支付通知回调URL
    Route::get('/pay/alipay/notify', [PayController::class, 'alipay_notify']);
    // 支付宝支付结果验证
    Route::post('/pay/alipay/check_result', [PayController::class, 'alipay_return']);

    // 充值卡领取
    Route::post('/card/query', [CardController::class, 'query']);
    // 获取充值卡信息
    Route::post('/card/get_card_info', [CardController::class, 'get_card_info']);

    // 确认充值
    Route::post('/topup/confirm_topup', [TopUpController::class, 'confirm_topup']);
    // 充值结果回调
    Route::get('/topup/notify', [TopUpController::class, 'notify']);
});

// 需要鉴权的路由
Route::prefix('v1')->middleware([AuthMiddleware::class])->group(function(){
    // 获取个人信息
    Route::get('/user/get_self_info', [UserController::class, 'get_self_info']);
    // 获取支付报表
    Route::post('/manager/report/get_pay_report', [ReportController::class, 'get_pay_report']);
    // 获取充值卡报表
    Route::post('/manager/report/get_card_report', [ReportController::class, 'get_card_report']);
    // 获取充值报表
    Route::post('/manager/report/get_topup_report', [ReportController::class, 'get_topup_report']);
    // 获取系统配置
    Route::get('/system/manager_get_env_info', [SystemController::class, 'manager_get_env_info']);
    // 修改/设置系统配置
    Route::post('/system/set_env_info', [SystemController::class, 'set_env_info']);
});
